rm(list=ls())

##############################################################################
# APPENDIX B3 TABLE 1
##############################################################################

# load packages
#library(texreg)

# load data 
load("data/candidate_GCI.RData")

##############
# RUN MODELS #
##############

LM1 <- lm(votes ~ ranking + factor(region), data = candidate_GCI)
#summary(LM1)

LM2 <- lm(votes ~ ranking + factor(region) + log_gdp_percap, data = candidate_GCI)
#summary(LM2)

LM3 <- lm(votes ~ ranking + factor(region) + log_gdp_percap + 
            log_pop + idealpoint_US + idealpoint_RU + nato_bin + eu_bin + g77_bin + oic_bin, data = candidate_GCI)
#summary(LM3)

################
# CREATE TABLE #
################

appendB3_tab1 <- screenreg(list(LM1,LM3), custom.coef.map = list("votes" = "votes", 
                                                "ranking" = "ranking", 
                                                "log_gdp_percap" = "log GDP percap", 
                                                "log_pop" = "log population", 
                                                "idealpoint_US" = "UN voting (distance from US)", 
                                                "idealpoint_RU" = "UN voting (distance from Russia)",
                                                "nato_bin" = "NATO", 
                                                "eu_bin" = "EU", 
                                                "g77_bin" = "G77", 
                                                "oic_bin" = "OIC"),
          omit.coef = c("region", "elect_year", "Constant"), 
          custom.gof.rows = list("Region FE" = c("YES", "YES"), 
                                 "Controls" = c("NO","YES")), digits = 3, 
          stars = c(0.001, 0.01, 0.05, 0.1)) 

print(appendB3_tab1)

# script complete message 
print("appendB3_tab1 complete")
